package com.bristua.common.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.Map;

/**
 * Created by Administrator on 2017/9/22 0022.
 */
public class JsonUtil {
    private final static Gson gson =new GsonBuilder().serializeNulls().create();

    public static String toJson(Object obj) {
        return gson.toJson(obj);
    }

    public static Map json2Map(String json) {
        return gson.fromJson(json, Map.class);
    }

    public static Object json2Object(String json, Class cls) {
        return gson.fromJson(json, cls);
    }
}
